Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

83
Views
Pass const present in other function as a props | React class component

I have this view which is in the Controller, and item is passed as a prop.

render () {
    if (this.view) {
        const { item } = this.props;
        return <ViewComponent 
            item = {item}
        />;
    }
}

I have this other function save() which creates and save the payload.

I need to pass this payload as well present it to the save function as a prop to my view so I can use it.

save () {
    const payload = constructPayloadFunction();
    createFunction({ payload });
}

How do I do that?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You have to create a function in you Controller

public createFunction(payload){....}

and pass this as a prop to your ViewComponent

if (this.view) {
   const { item } = this.props;
   return <ViewComponent 
   item = {item}
   createFunction = {createFunction}
   />;
}

and finally, in your save function, just pass the result

const payload = constructPayloadFunction();
createFunction(payload);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!